package copyengine.utils.delayEffect.logic
{
	import copyengine.utils.GeneralUtils;

	public final class CEDelayEffectExecuteWarpManger
	{
		private var allDelayEffectVector:Vector.<CEDelayEffectExecuteWarp>;

		public function CEDelayEffectExecuteWarpManger()
		{
		}

		public function initialize():void
		{
			allDelayEffectVector = new Vector.<CEDelayEffectExecuteWarp>();
		}

		public function dispose():void
		{
			while (allDelayEffectVector.length > 0)
			{
				allDelayEffectVector.pop().dispose();
			}
			allDelayEffectVector = null;
		}

		public function finishAllDelayEffectImmediately():void
		{
			for each (var warp:CEDelayEffectExecuteWarp in allDelayEffectVector)
			{
				warp.finishAllDelayEffectImmediately();
			}
		}

		public function addExecuteWarp(_warp:CEDelayEffectExecuteWarp, _flowFinishCallBack:Function):void
		{
			_warp.initialize(_flowFinishCallBack, this);
			allDelayEffectVector.push(_warp);
		}

		public function removeExecuteWarp(_warp:CEDelayEffectExecuteWarp):void
		{
			var result:Boolean = GeneralUtils.removeElementFromArrayOrVector(_warp, allDelayEffectVector);
			result && _warp.dispose();
		}

	}
}
